<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      class User {}

      function ConstructorProxy(Class, ...propNames) {
        return new Proxy(Class, {
          construct(target, argumentsList) {
            const obj = Reflect.construct(target, argumentsList);
            propNames.forEach((name, i) => {
              obj[name] = argumentsList[i];
            });
            return obj;
          },
        });
      }

      const UserProxy = ConstructorProxy(User, "firstName", "lastName", "age");
      const obj = new UserProxy("z", "s", 18);
      console.log(obj);
    </script>
  </body>
</html>
